package com.zto.sch.base.normal;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.digest.MD5;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import org.junit.Test;

import javax.swing.*;
import java.util.Arrays;

/**
 * @program: sch-diy-parent
 * @description:
 * @author: sch
 * @create: 2021-03-26 10:10
 **/
public class StringTest {
    public static void main(String[] args) {
        String aa = "Test";
        String bb = "Test";

        System.out.println(aa == bb);
//        System.out.println(aa.toUpperCase() + "::" + bb);
//        System.out.println("Test".toUpperCase() + "::" + bb);
        JPasswordField jPasswordField = new JPasswordField("abcdefgHG1234");
        char[] password = jPasswordField.getPassword();
        System.out.println(Arrays.toString(password));
    }

    @Test
    public void test1() {
        String format = String.format("%s/%s/%s", "a", "b", "c");
        System.out.println(format);
        String format1 = String.format("%s/%s/%s", "上海", "", "");
        System.out.println(format1);
    }

    /**
     * replaceAll calls the java.util.regex.Pattern.compile() method each time
     * it is called even if the first argument is not a regular expression
     */
    @Test
    public void testReplace() {
//        String srcStr = "aaa/bbb55%%...;+ccc???ccc";
//        String resultStr = srcStr.replaceAll("\\+", "")
//                .replaceAll("%", "")
//                .replaceAll("/", "")
//                .replaceAll("\\?", "");
//
//        String resultStr2 = srcStr.replaceAll("\\+", "")
//                .replace("%", "")
//                .replace("/", "")
//                .replace("?", "");
//        System.out.println(srcStr+"======================="+resultStr);
//        System.out.println(srcStr+"======================="+resultStr2);

//        String str3 = "[{\"value\":\"[\\\"900cm<sup>3</sup>\\\"]\",\"alternativeValues\":null,\"audioUrl\":null,\"questionContent\":null}]";
//        JSONArray values = JSON.parseArray(str3);
////        String str3  = "";
//        String[] splitStr3s = str3.substring(1, str3.length() - 1).split("[,，;；]+");
//
//        String str3Replace = str3.replace("<[^>]*>", " ");
////                replace("[", "").
////                replace("]", "").
////                replace("\"","");
//        System.out.println(str3+"----"+str3Replace);
//
//        String str3ReplaceAll = str3.replaceAll("<[^>]*>", "").trim();
//        System.out.println(str3ReplaceAll);


//        String init = "Bob is a Bird... Bob is a Plane... Bob is Superman!";
//        String changed = init.replaceAll("Bob is", "It's"); // Noncompliant
//        changed = changed.replaceAll("\\.\\.\\.", ";"); // Noncompliant
//        System.out.println(init + "---------" + changed);
//
//        String init2 = "Bob is a Bird... Bob is a Plane... Bob is Superman!";
//        String changed2 = init.replace("Bob is", "It's");
//        changed2 = changed2.replace("...", ";");
//        System.out.println(init2 + "--------------" + changed2);

//        String init = "Bob is a Bird... Bob is a Plane... Bob is Superman!";
//        String changed = init.replaceAll("\\w*\\sis", "It's");
//        changed = changed.replaceAll("\\.{3}", ";");
        String htmlStr = "[\"<div>0</div>\",\"0\"]";
        System.out.println(htmlStr+"====="+htmlStr.replaceAll("<[^>]*>",""));

    }


    @Test
    public void testOnlyOneFlag(){
//        String s = SecureUtil.md5("123456");
//        MD5 md5 = new MD5();
//        String s1 = md5.digestHex("123456");
//        System.out.println(s+"===="+s1);
//
//        System.out.println(SecureUtil.sha256("123456"));



        String str1 = "{\"printType\":2,\"showStuGardenFlag\":true,\"showGardenOrScoreType\":1,\"wrongOrRightType\":1,\"markAnswerType\":1,\"leaveMarkType\":0}";
        String str2 = "{\"printType\":2,\"showStuGardenFlag\":true,\"showGardenOrScoreType\":1,\"wrongOrRightType\":1,\"markAnswerType\":2,\"leaveMarkType\":0}";
        String ss1 = SecureUtil.md5(str1);
        String ss2 = SecureUtil.md5(str2);
        System.out.println(ss1+"----"+ss2);

    }
    @Test
    public void testSubStr(){
        String str = "$aabbcc";
        System.out.println(str.substring(1,str.length()));

    }

}
